
import { BaseEntity, Column, Entity, JoinTable, ManyToMany, ManyToOne, OneToMany, PrimaryGeneratedColumn, Tree, TreeChildren, TreeParent } from "typeorm";
import { RoleEntity } from "./role.entity";

@Entity({ name: 'menu' })
export class MenuEntity extends BaseEntity{
    @PrimaryGeneratedColumn()
    id: number;//菜单id

    @Column({ type: 'varchar', length: 50 })
    menutype: string;//1：表示菜单 ， 2 :表示按钮

    @Column({ type: 'varchar', length: 50 })
    menuName: string;//菜单名称

    @Column({ type: 'varchar', length: 50 })
    path: string;//菜单URL

    @Column({ type: 'varchar', length: 50 })
    icon: string;//图标

    @Column({type:'int'})
    pid: number;//父菜单id


    @ManyToOne(type => MenuEntity, menuEntity => menuEntity.children)
    parent: MenuEntity;

    @OneToMany(type => MenuEntity, menuEntity => menuEntity.parent)
    children: MenuEntity[];

    @Column({type:'tinyint'})
    isDeleted:boolean


    @ManyToMany(
        () => RoleEntity,
        role => role.menu
    )
    role: RoleEntity[];

}